package com.nginx.web.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class PageQo {

    @ApiModelProperty("分页")
    private Integer page = 1;
    @ApiModelProperty("分页大小")
    private Integer limit = 10;

    /**
     * 第一条记录索引
     */
    @ApiModelProperty(value = "第一条记录索引",hidden = true)
    private Integer firstRecord = 0;
    @ApiModelProperty(value = "后记录索引",hidden = true)
    private Integer lastIndex = 10;
    /**
     * 计算第一条记录索引
     */
    private void computefirstRecord(){
        if(page != null && limit != null){
            this.firstRecord =  (page - 1) * limit;
            this.lastIndex = this.firstRecord + this.limit;
        }
    }

    public void setPage(Integer page) {
        this.page = page;
        this.computefirstRecord();
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
        this.computefirstRecord();
    }
}
